Print webpage as pdf 您所在的位置:网站首页 save or print webpage as pdf Print webpage as pdf

Print webpage as pdf

2023-03-15 11:10| 来源: 网络整理| 查看: 265

Hello everyone,

Here is my approach to saving a webpage as a pdf using windows 10 pro and chrome. Use a start process activity to start headless chrome with arguments to save/print to pdf. It works pretty well and renders web pages as you would expect. I have read of issues with formatting using some approaches. If you have chrome installed, then no additional software installation is required. I found this approach more reliable than printing as pdf through the chrome user interface.

If your robot/app needs to enter values into a web page form prior to saving, I would consider entering those values and then saving the resultant html file (uses the windows save dialog which IMO is much more friendly to automation than the chrome print dialog). Then feed the html to the headless chrome.

Perhaps this is all easier with Internet Explorer or Edge, but I needed Chrome.

SavePDFofWebpageUsingHeadlessChrome.xaml (5.7 KB)

image image525×572 33.3 KB

image

Caveats:

Running headless chrome instances on my machine (Windows 10 pro) seemed to generate a lot of background chrome processes that were failing to close/exit. Then as I continued to use my robot to generate PDFs, the system would freeze after it had too many chrome instances (I think anyway). So I upgraded Chrome, after which nothing worked. This sent me down several rabbit holes. At the end of the day, I needed to update my chrome driver to match the updated chrome. After both Chrome and Chrome Driver were updated, I no longer had issues with chrome instances failing to exit. Prior to the updates, my system would freeze at about 20. I’ve tested the above with 60 separate instances with no issues. The approach above is I believe a low tech/ newb way to acheieve some of the functions of puppeteer. See GitHub - puppeteer/puppeteer: Headless Chrome Node.js API


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有